import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/material.dart';
import '../../widget/my_image.dart';

class GoodStatus extends StatefulWidget {
  @override
  _GoodStatusState createState() => _GoodStatusState();
}

class _GoodStatusState extends State<GoodStatus>
    with SingleTickerProviderStateMixin {
  TabController controller;

  List goodStatus = ['待付款', '待发货', '待收货', '待评价', '已完成'];

  @override
  void initState() {
    //initialIndex初始选中第几个
    controller =
        TabController(initialIndex: 0, length: goodStatus.length, vsync: this);
    super.initState();
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          Container(
            width: 750.w,
            height: 150.w,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(15.w)),
                color: Colors.white),
            child: TabBar(
              controller: controller,
              //可以和TabBarView使用同一个TabController
              tabs: goodStatus.map((e) {
                return Tab(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [Text('${e}'), Text('1')],
                  ),
                );
              }).toList(),
              isScrollable: false,
              indicatorColor: Color(0xffff0000),
              indicatorWeight: 3,
              indicatorSize: TabBarIndicatorSize.label,
              labelColor: Color(0xff333333),
              labelStyle: TextStyle(
                fontSize: 25.sp,
                  fontWeight: FontWeight.bold
              ),
              unselectedLabelColor: Colors.black,
              unselectedLabelStyle: TextStyle(
                fontSize: 12.0,
              ),
            ),
          ),
          Container(
            width: 750.w,
            height: 800.w,
            decoration: BoxDecoration(color: Colors.white),
            child: TabBarView(
              physics: BouncingScrollPhysics(),
                controller: controller, //配置控制器
                children: goodStatus.map((e) {
                  return Container(
                    padding: EdgeInsets.symmetric(horizontal: 25.w,vertical: 25.w),
                    child: Column(
                      children: [
                        Container(
                          height: 100.w,
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Text('2020-5-9 23:23:00'),
                              Text(
                                '${e}',
                                style: TextStyle(
                                    color: Colors.red,
                                    fontSize: 35.sp),
                              )
                            ],
                          ),
                        ),
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Container(
                              height: 150.w,
                              width: 150.w,
                              child: ClipRRect(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(15.w)),
                                child: MyImage(
                                  imgSrc:
                                      'https://img.tupianzj.com/uploads/allimg/200420/30-200420105004.jpg',
                                ),
                              ),
                            ),
                            SizedBox(
                              width: 25.w,
                            ),
                            Expanded(
                              child: Text(
                                '打印机真好的爱的发声飞洒地方阿斯蒂芬阿斯蒂芬阿斯蒂芬阿斯蒂芬阿斯蒂芬暗室逢灯',
                                overflow: TextOverflow.ellipsis,
                                maxLines: 2,
                              ),
                            ),
                            SizedBox(
                              width: 25.w,
                            ),
                            Column(
                              children: [Text('￥100.00',style: TextStyle(
                                  color: Colors.grey,
                                  fontSize: 35.sp
                              )),
                                SizedBox(
                                  height: 25.w,
                                ),Text('x1',style: TextStyle(
                                color: Colors.grey,
                                fontSize: 35.sp
                              ),),],
                            )
                          ],
                        ),
                        SizedBox(height:30.w),
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Container(
                              height: 150.w,
                              width: 150.w,
                              child: ClipRRect(
                                borderRadius:
                                BorderRadius.all(Radius.circular(15.w)),
                                child: MyImage(
                                  imgSrc:
                                  'https://img.tupianzj.com/uploads/allimg/200420/30-200420105004.jpg',
                                ),
                              ),
                            ),
                            SizedBox(
                              width: 25.w,
                            ),
                            Expanded(
                              child: Text(
                                '打印机真好的爱的发声飞洒地方阿斯蒂芬阿斯蒂芬阿斯蒂芬阿斯蒂芬阿斯蒂芬暗室逢灯',
                                overflow: TextOverflow.ellipsis,
                                maxLines: 2,
                              ),
                            ),
                            SizedBox(
                              width: 25.w,
                            ),
                            Column(
                              children: [Text('￥100.00',style: TextStyle(
                                  color: Colors.grey,
                                  fontSize: 35.sp
                              )),
                                SizedBox(
                                  height: 25.w,
                                ),Text('x1',style: TextStyle(
                                    color: Colors.grey,
                                    fontSize: 35.sp
                                ),),],
                            )
                          ],
                        ),

                        Row(
                          mainAxisAlignment: MainAxisAlignment.end,
                          children: [
                            Container(
                              height:100.w,
                              child: RichText(
                                text: TextSpan(
                                    children: [
                                      TextSpan(
                                          text: '共2见商品,总金额',style: TextStyle(
                                          color: Colors.black
                                      )
                                      ),
                                      TextSpan(
                                          text: '￥500.00',style: TextStyle(
                                          color: Colors.red
                                      )
                                      )
                                    ]
                                ),
                              ),
                            )
                          ],
                        )
                      ],
                    ),
                  );
                }).toList()),
          ),

        ],
      ),
    );
  }
}
